<template lang="">
    <div>
        <van-field  label='用户名' v-model='form.name'/>
        <van-field  label='密码' v-model='form.password'/>
        <van-button @click='login'>登录</van-button>
    </div>
</template>
<script>
import axios from 'axios'
export default {
    data(){
        return{
            form:{}
        }
    },
    methods: {
        login(){
            axios.post('http://localhost:5000/userlogin',this.form).then(res=>{
                //存储用户名和资源信息
                localStorage.setItem('uid',res.data.userid)
                localStorage.setItem('uname',res.data.name)
                localStorage.setItem('resourcelist',JSON.stringify(res.data.resourcelist))
                this.$router.push('menu')
            })
        }
    },

}
</script>
<style lang="">
    
</style>